

//
//  StatusViewModel.m
//  kuangjia
//
//  Created by 张帅 on 15/10/2.
//  Copyright © 2015年 ZhangShuai. All rights reserved.
//

#import "StatusViewModel.h"

@implementation StatusViewModel


-(instancetype)initWithStatus:(Status *)status{
    
    if (self=[super init]) {
        
        self.status =status;
       
 
    NSArray *url = status.retweeted_status.pic_urls ? status.retweeted_status.pic_urls: status.pic_urls;
        
             self.thumbnailURLs  = [NSMutableArray array];
            
            for (NSDictionary *dict in url) {
                
                [self.thumbnailURLs addObject:[NSURL URLWithString:dict[@"thumbnail_pic"]]];
            }


    }
    return self;
}

-(NSMutableArray *)bmiddleURLs{

    
    NSArray * urls =self.thumbnailURLs;
    if (!urls) {
        return nil;
    }
    NSMutableArray *array =[NSMutableArray array];
    
    for (NSURL *url in urls) {
        NSString *urlString= [url.absoluteString stringByReplacingOccurrencesOfString:@"/thumbnail/" withString:@"/bmiddle/"];
        [array addObject:urlString];
        
    }
    return array;

}


-(NSURL *)userIconUrl{

    return [NSURL URLWithString:self.status.user.profile_image_url];
}


-(UIImage *)userMemberImage{

    if (self.status.user.mbrank>0&&self.status.user.mbrank<7) {
        return [UIImage imageNamed:[NSString stringWithFormat:@"common_icon_membership_level%d",self.status.user.mbrank]];
    }
    return nil;
}

-(UIImage *)userVipImage{

    switch (self.status.user.verified ) {
        case 0:
            return [UIImage imageNamed:@"avatar_vip"];
            break;

            case 1:
            return [UIImage imageNamed:@"avatar_vip"];
             break;
            case 2:
            case 3:
            case 5:
            return [UIImage imageNamed:@"avatar_enterprise_vip"];
            break;
            case 220:
            return [UIImage imageNamed:@"avatar_grassroot"];
            break;
            
         default:
            return nil;
            break;
    }
}


-(NSString *)forwardText{
    
    NSString *username = self.status.retweeted_status.user.name;
    
    username =username?username:@"";
    
    NSString *text = self.status.retweeted_status.text;
 
    text = text? text:@"";
    
    NSString * forText =[NSString stringWithFormat:@"@%@:%@",username,text];
    return forText;
    
    
}


- (NSString *)cellID{
 
    return self.status.retweeted_status!=nil ? HMStatusForwardCellID:HMStatusNormalCellID;
}
@end
